<?php

namespace api\wxapp\model;

use think\Model;
use api\wxapp\model\User;
class Diary extends Model
{
    protected $table = 'sssc_app_diary';
    ///护肤日记
    public function getList($page,$uid = 0)
    {
        $where = array();
        if($uid){
            $where[] = ['uid','eq',$uid];
        }
        return self::where($where)->limit(($page-1)*10,10)->order('id','desc')->all()
        ->each(function($item,$key){
            $user = User::get($item['uid']);
            $item['nickname'] = $user['nickname'];
            $item['userimg'] = $user['img'];
            $item['img'] = json_decode($item['img']);
        });
    }
    public function info($id)
    {
        $info = self::get($id);
        $user = User::get($info['uid']);
        $info['img'] = json_decode($info['img']);
        $info['nickname'] = $user['nickname'];
        $info['userimg'] = $user['img'];
        return $info;
    }
}
